<template>
  <view class="order-recycle-way-component">
    <view
      v-if="showTitle"
      class="order-recycle-way-title"
    >
			<hsb-business-order-title-cell
				:title="orderCellTitle"
				:showRight="false"
			/>
    </view>
    <view class="order-recycle-way">
      <!-- 顺丰上门/回收宝上门/自行邮寄 -->
      <view v-if="showVisitModule || showPostModule" class="order-recycle-visit">
        <view class="order-recycle-pdtb14">
          <view class="order-name-phone">
            <text class="name">{{ showPostModule ? '回收宝' : orderInfo.userName || '' }}</text>
            <text class="phone">{{ showPostModule ? '18123877635' : orderInfo.tel || '' }}</text>
          </view>
          <view class="visit-address">
            <template v-if="showPostModule">深圳市福田区华强北曼哈商业广场A座3楼</template>
            <template v-else>{{ orderInfo.province || '' }}{{ orderInfo.city || '' }}{{ orderInfo.county || '' }}{{ orderInfo.addr || '' }}</template>
          </view>
        </view>
        <view v-if="showVisitModule && showVisitTimeModule" class="visit-time">预约时间：{{ orderInfo.visitTime }}</view>
      </view>
      <!-- 快递柜邮寄 -->
      <view v-else-if="showBoxModule" class="order-recycle-box">
        <view class="order-recycle-pdtb14">
          <view class="box-code">寄件码：<text class="code-txt">{{ orderInfo.code || '暂无寄件码' }}</text></view>
        </view>
      </view>
      <!-- 到店回收 -->
      <view v-else-if="showStoreModule" class="order-recycle-store">
        <view class="order-recycle-pdtb14">
          <view class="store-address">门店地址：{{ orderInfo.customData.addressTip || '暂无门店信息' }}</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { orderStatusMap, orderCellTitleMap } from '@/config'

export default {
	props: {
		orderInfo: Object,
		routeList: Array
	},
	computed: {
		showVisitModule () {
			return ['1', '2'].includes(this.orderInfo.recycleType) &&
						 Boolean(orderStatusMap.recycleWayMap[this.orderInfo.orderStatusNo]) &&
			       this.routeList.length === 0
		},
		showPostModule () {
		  return Boolean(orderStatusMap.postSelfMap[this.orderInfo.orderStatusNo]) &&
		         this.routeList.length === 0
		},
		showBoxModule () {
		  return ['4', '5'].includes(this.orderInfo.recycleType) &&
		         Boolean(orderStatusMap.boxCodeMap[this.orderInfo.orderStatusNo]) &&
		         this.routeList.length === 0
		},
		showStoreModule () {
		  return ['6'].includes(this.orderInfo.recycleType)
		},
		showVisitTimeModule () {
		  return Boolean(orderStatusMap.visitTimeMap[this.orderInfo.orderStatusNo]) &&
		         Boolean(this.orderInfo.visitTime)
		},
		showStoreTimeModule () {
		  return Boolean(orderStatusMap.storeTimeMap[this.orderInfo.orderStatusNo]) &&
		         Boolean(this.orderInfo.customData?.bookTime)
		},
		orderCellTitle () {
		  if (this.orderInfo.orderStatusNo === '13') {
		    return '平台地址'
		  }
		  if (orderCellTitleMap[this.orderInfo.recycleType]) {
		    if (this.orderInfo.recycleType === '6') {
		      return this.orderInfo.customData?.store || orderCellTitleMap[this.orderInfo.recycleType]
		    }
		    return orderCellTitleMap[this.orderInfo.recycleType]
		  }
		  return '基本信息'
		},
		showTitle () {
			return this.showVisitModule || this.showPostModule || this.showBoxModule || this.showStoreModule
		}
	}
}

</script>

<style lang="scss" scoped>
@import './index.scss';
</style>
